package com.zq.common.exception;


import com.zq.common.util.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @Author 张乔
 * @Date 2023/12/22 20:15
 */
@RestControllerAdvice
@Slf4j
public class VoResultException {
//    自定义异常处理类
@ExceptionHandler(ResultException.class)
public Result<String> errorResult(ResultException resultException){
    log.error("自定义异常处理抛出的错误信息==========>"+resultException.getMessage());

return new Result<>(resultException.getCode(),resultException.getMessage(),null);
}

//全局异常处理类
    @ExceptionHandler(Exception.class)
    public Result<String> error(Exception e) {
log.error("全局异常处理抛出的错误信息================>"+e.getMessage());

    return new Result<String>(555,e.getMessage(),null);
    }



}
